1. Field of the Invention
This invention relates to a data structure for texture data, and in particular to a data structure appropriate for cell shading.
2. Description of the Related Art
In conventional computer graphics, a technique called cell shading is known as a method of texture mapping using multiple textures. Cell shading is also called toon shading; in this shading method, the distance between the object(the model) for texture mapping and the light source, as well as the angles made by normal vectors to the object surface, are used to compute texture data UV coordinates (read addresses), and brightnesses and colors are appropriately filtered and textures mapped to the object surface. FIG. 8 is a figure explaining the texture data used in conventional cell shading. The texture data 70 shown in the figure is used for shading processing from white to black when the brightness of the object surface exceeds a constant threshold, and in the normalized UV coordinate system (0.0≦U≦1.0 and 0.0≦V≦1.0), comprises data regions 71 in which “white” data (0.0≦U≦0.5 and 0.0≦V≦1.0) is allocated as well as data regions 72 in which “black” data (0.5≦U≦1.0 and 0.0≦V≦1.0) is allocated UV coordinates referenced during texture mapping can be computed using the following two equations.U=a*I+b  (1)V=c*I+d  (2)
Here I is the brightness value, computed from the inner product of the normalized normal vector to the object surface and the normalized light ray vector, and a, b, c, d are constants. Because the cell shading method is well known, the details of a, b, c, d are here omitted. If the brightness I can be computed, the UV coordinates for the texture data can be computed from equations (1) and (2). The movement locus of UV coordinates when the value of the brightness I is changed is similar to the straight line 73. As is clear from the figure, as a result of light source calculations, when setting the UV values at each vertex of the object, a small U value is specified and white texture mapping is performed at each portion for which the angle made by the object surface normal vector and the light ray vector is small and on which a large amount of light is incident; on the other hand, a large U value is specified and black texture mapping is performed at each portion for which the angle made by the object surface normal vector and the light ray vector is large and on which not much light is incident. In other words, when the U value exceeds 0.5, pixels on the object surface are shaded from white to black. Thus by performing shading processing using the two values of white and black, the difference between exposed faces and unexposed faces on the object surface can be made apparent, and so-called animation-style shading can be performed.
However, in conventional cell shading methods, it is necessary to prepare texture data for shading according to the light source color, distance between light source and object, light intensity of the light source, and other exposure conditions, and consequently there are the problems of additional labor for the designer, and waste of hardware resources. Further, in the past object details were represented in texture mapping by applying a two-dimensional design or pattern to a two-dimensional plane; but when texture mapping is employed for shading as described above, because texture data for shades suffices in only a single-dimension direction, the use of two-dimensional texture data as texture data for shading results in wasted memory. This problem is explained referring to FIGS. 9 and 10.
FIG. 9 explains a case in which the texture data to be used is changed according to the color of the light source; as the light sources illuminating the object 50, a red light source 41, green light source 42, and blue light source 43 are arranged in a virtual space. Three types of texture data are prepared for binary shading processing according to each light source color. In the state shown in the drawing, because the object 50 is in the position of the green light source 42, texture data for green shading processing is used to perform texture mapping. However, when the object 50 crosses the boundary 61 between the red light source 41 and green light source 42 to move to the side of the red light source 41, the texture data for the green light source 42 can no longer be used for shading, and shading must be performed using the texture data for the red light source 41. When the texture data to be used is suddenly changed at the border line 61, the shading displayed on the surface of the object 50 suddenly changes, and the appearance of the graphic display is extremely unnatural. The case in which the object 50 crosses the boundary 62 between the green light source 42 and blue light source 43 to move to the side of the blue light source 43 is similar.
FIG. 10 explains a case in which the texture data used is changed according to the positional relation between the camera (virtual viewpoint) and object; the light source 40, object 50, and camera 60 are arranged in prescribed positions. In three-dimensional computer graphics, each of the polygons comprised by the object 50 is modeling-transformed into world coordinates, and after performing field-of-view transformation to the camera viewpoint as seen from the camera 60, three-dimensional clipping processing, hidden surface elimination, texture mapping, shading processing, display priority processing, and other processing, the result is displayed on a video display. Because the shading to which the object 50 is subjected is viewed differently according to the distance between the camera 60 and object 50, texture data for a plurality of types of shading processing are prepared in advance, and when the distance between the object 50 and camera 60 exceeds a certain distance, the texture used in shading is changed. In the example of the drawing, when the object 50 crosses over the boundary 63 and moves farther from the camera 60, the texture used is changed. However, if the texture used changes suddenly at the boundary 63, the shades displayed on the surface of the object 50 changes suddenly, and the appearance of the graphic display is extremely unnatural.
However, of the texture data 70 shown in FIG. 8, the data actually used is only the data on the straight line 73, and the other data regions are not used, and the problem of considerable waste of memory for texture data storage has been noted.